﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using QuanLyHocPhi.Entity;
using QuanLyHocPhi.DAL;
namespace QuanLyHocPhi
{
    public partial class FrmLoaiLop : Form
    {
        IList<DOI_TUONG> danhsach=null;
        IList<MUC_PHI> dsMucPhi = null;
        DOI_TUONG loaiLopHienTai=null;
        MUC_PHI mucPhiHienTai = null;
        MUC_PHI_DAO daoMucPhi = new MUC_PHI_DAO();
        public DOI_TUONG LoaiLopHienTai { get { return loaiLopHienTai; } }
        public MUC_PHI MucPhiHienTai { get { return mucPhiHienTai; } }
        public FrmLoaiLop(IList<DOI_TUONG> dsLoaiLop)
        {
            InitializeComponent();
            danhsach = dsLoaiLop;
            cbbLoaiLop.DisplayMember = "TEN_DOI_TUONG";
            cbbLoaiLop.ValueMember = "MA_DOI_TUONG";            
            cbbLoaiLop.DataSource = dsLoaiLop;
            cbbLoaiLop.SelectedIndex = -1;
            cbbLoaiLop.Text = "[Chọn loại lớp]";
        }

        private void FrmLoaiLop_Load(object sender, EventArgs e)
        {

        }

        private void btnOK_Click(object sender, EventArgs e)
        {
            if (cbbLoaiLop.SelectedIndex < 0 || cbbMucPhi.SelectedIndex<0)
            {
                MessageBox.Show("Vui lòng chọn loại lớp và số lần thanh toán");
                return;
            }
            loaiLopHienTai=danhsach[cbbLoaiLop.SelectedIndex];
            this.mucPhiHienTai = dsMucPhi[cbbMucPhi.SelectedIndex];
            this.Close();
        }

        private void cbbLoaiLop_SelectedIndexChanged(object sender, EventArgs e)
        {
            if (cbbLoaiLop.SelectedIndex > -1)
            {
                loaiLopHienTai = danhsach[cbbLoaiLop.SelectedIndex];
                dsMucPhi = daoMucPhi.SelectByObjectId(loaiLopHienTai.MA_DOI_TUONG);
                cbbMucPhi.DisplayMember = "SO_LAN_THANH_TOAN";
                cbbMucPhi.ValueMember = "SO_LAN_THANH_TOAN";
                cbbMucPhi.DataSource = dsMucPhi;
                cbbMucPhi.SelectedIndex = -1;
                cbbMucPhi.Text = "[Chọn số lần thanh toán]";
            }
        }

        private void cbbMucPhi_SelectedIndexChanged(object sender, EventArgs e)
        {
           
        }
    }
}
